package com.me.shop.category.adminaction;

import java.util.List;

import com.me.shop.category.bean.Category;
import com.me.shop.category.service.CategoryService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class AdminCategoryAction extends ActionSupport implements ModelDriven<Category> {
	private Category category = new Category();
	public Category getModel() {
		return category;
	}
	
	private CategoryService categoryServie;
	public void setCategoryServie(CategoryService categoryServie) {
		this.categoryServie = categoryServie;
	}
	
	public String findAll() {
		List<Category> cList = categoryServie.findAll();
		ActionContext.getContext().getValueStack().set("cList", cList);
		return "findAll";
	}
	
	public String save() {
		categoryServie.save(category);
		return "saveSuccess";
	}
	
	public String delete() {
		category = categoryServie.findByCid(category.getCid());
		categoryServie.delete(category);
		return "deleteSuccess";
	}
	
	public String edit() {
		category = categoryServie.findByCid(category.getCid());
		return "editSuccess";
	}
	
	public String update() {
		categoryServie.update(category);
		return "updateSuccess";
	}
	
}




















